<template>
  <div class="percentage">
    <div class="percentage-item" v-for="item in starList" :key="item.rank">
      <span>{{ item.rank }}星</span>
      <div class="bar-chart">
        <div class="bar" :style="{ width: item.percentage * 100 + '%' }"></div>
        <div class="percentage">{{ item.percentage * 100 }}%</div>
      </div>
    </div>
  </div>
</template>
    
    <script>
export default {
  data() {
    return {};
  },
  props: {
    starList: {
      type: Array,
      default: () => [],
      required: true,
    },
  },
};
</script>

<style lang="less" scoped>
.percentage {
  .percentage-item {
    display: flex;
    justify-content: space-between;
    width: 176px;
    span {
      font-size: 14px;
    }
    .bar-chart {
      width: 140px;
      display: flex;
      align-items: center;
      .bar {
        width: 100%;
        height: 12px;
        background-color: rgb(255, 213, 150);
        transition: width 0.5s ease;
      }
      .percentage {
        color: #888;
        margin-left: 6px;
        font-size: 14px;
      }
    }
  }
}
</style>